import { PoolConnection, Pool} from 'mysql'
export default (sql: string, pool: Pool) => {
  return new Promise((resolve, reject) => {
    pool.getConnection((error: Error, connection: PoolConnection) => {
      if (error) {
        reject(error)
      } else {
        connection.query(sql, (error, results) => {
          if (error) reject(error)
          resolve(results)
          connection.release()
        })
      }
    })
  })
}
